<?php
namespace app\admin\model;

use think\Model;

class Goods extends Model 
{
    public function searchKeywordsAttr($q,$v,$d)
    {
        $q->where('g.name','like',"%{$v}%");
    }

    public function searchIsShowAttr($q,$v,$d)
    {
        $q->where('g.is_show','=',$v);
    }

    public function searchIsDownAttr($q,$v,$d)
    {
        $q->where('g.is_down','=',$v);
    }

    public function searchIsHotAttr($q,$v,$d)
    {
        $q->where('g.is_hot','=',$v);
    }

    public static function all($where)
    {
        $list=Goods::alias('g')->join('category c','g.cid=c.id')->field('g.*')->field('c.name cname')->withSearch(array_keys($where),$where)->select();
        return $list;
    }

//
}